package ch.usi.inf.pf2;

import java.io.IOException;

import ch.usi.inf.pf2.gui.JSpreadSheetGUI;

/**
 * The main class, which run the program
 * @author Thomas Mantegazzi, Yotam Sharon, Lorenzo Baracchi and Ebrisa Savina Mastrodicasa
 *
 */

public class SpreadSheet {
	
	/*public static void main(String[] args) {
		System.out.println("Application Started");
		System.out.println("Starting GUI");
		SpreadSheetGUI SpSG = new SpreadSheetGUI();
	}*/
	
	public static void main(String[] args) {
		System.out.println("Application started");
		System.out.println("Reading file");
		ReadSpreadSheetFile rssf = new ReadSpreadSheetFile("test");
		Sheet s = new Sheet();
		s.initializeSheet();
		try {
			s = rssf.readSheet();
		} catch (IOException e) {
			System.out.println("File not found.");
			e.printStackTrace();
		}
		System.out.println("File read");
		System.out.println("Starting GUI");
		JSpreadSheetGUI SpSG = new JSpreadSheetGUI(s);
	}

	/*public static void main(String[] args) {
		System.out.println("This is our spreadsheet super application!!");
		System.out.println();
		ReadSpreadSheetFile rssf = new ReadSpreadSheetFile("testWrite");
		Sheet s = new Sheet();
		s.initializeSheet();
		try {
			s = rssf.readSheet();
		} catch (IOException e) {
			System.out.println("File not found.");
			e.printStackTrace();
		}
		s.insertDataAtCell("ciao", 1, 4);
		SpreadSheetPrinter  printer = new SpreadSheetPrinter(s);
		printer.print();
		
	}
	
	*/
	
	// To see that cut, copy, paste work
	
/*	public static void main(String [] args) {
		Sheet s = new Sheet();
		ALU alu = new ALU(s);
		s.initializeSheet();
		// sum the contents of two cells
		s.insertDataAtCell("1", "A1");
		s.insertDataAtCell("100", "A2");
		s.insertDataAtCell("2", "B1");
		s.insertDataAtCell("10", "C5");
		s.insertDataAtCell("=A1 + A2", "B2");
		// power of the value of two cells
		s.insertDataAtCell("=sum(A1:B2)", "C4");
		alu.computeSheet();
		// copy content of a cell into another
		Copy cp = new Copy(s, 2, 1);
		Paste pt = null;
		try {
			pt = new Paste(s, 7, 3, cp);
		} catch (Exception e) {
			e.printStackTrace();
		}
		cp.evaluate();
		pt.evaluate();
		// cut content of a cell and paste into another
		
		Cut ct = new Cut(s, 2, 2);
		Paste pst = null;
		try {
			pst = new Paste(s, 5, 4, ct);
		} catch (Exception e) {
			e.printStackTrace();
		}
		ct.evaluate();
		pst.evaluate();
		
		
		Cut ct1 = new Cut(s, 5, 3);
		Paste pst1 = null;
		try {
			pst1 = new Paste(s, 8, 10, ct1);
		} catch (Exception e) {
			e.printStackTrace();
		}
		ct1.evaluate();
		pst1.evaluate();
		
		
	
		SpreadSheetPrinter  printer = new SpreadSheetPrinter(s);
		printer.print();
	}*/
}
